<script setup>
import { ref, computed, onMounted } from "vue";
//import TodoItemTable from "../components/todoitemtable.vue"
import { getlist,add } from "../request/todolist"
import {TodoColumns,TodoUrlSet,netUtil,States} from "../models/columns"
import { InitComponentData} from 'common-list'

const { tableData } = InitComponentData(netUtil,TodoUrlSet, 'id', {});
const pColumns = computed(() => {

const newColumns = TodoColumns.value.map((item) => {
  if (item.fieldName == 'state') {
    item.options = States.map((typeName,index) => { return { title: typeName, value: index } })
  } 
  return item
})

return newColumns
})

function onBeforeSave(row){
 const uid= localStorage.getItem('userid')
    row['userid']=uid
}
</script>

<template>

  <CommonList datatitle="待办事项" key-field-name="id" :table-data="tableData" :showImportBtn="true"
    :pageSizes="[2,5,10]"  :column-list="pColumns" :total-count="tableData.length" searchplaceholder="搜索" :use-select="false"
    @before-save="onBeforeSave">

    </CommonList>
</template>
<style>
</style>